<!-- HTML header for doxygen 1.8.6-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<title>OpenCV: Tesseract (master) installation by using git-bash (version&gt;=2.14.1) and cmake (version &gt;=3.9.1)</title>
<link href="../../opencv.ico" rel="shortcut icon" type="image/x-icon" />
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<script type="text/javascript" src="../../tutorial-utils.js"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
//<![CDATA[
MathJax.Hub.Config(
{
  TeX: {
      Macros: {
          matTT: [ "\\[ \\left|\\begin{array}{ccc} #1 & #2 & #3\\\\ #4 & #5 & #6\\\\ #7 & #8 & #9 \\end{array}\\right| \\]", 9],
          fork: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ \\end{array} \\right.", 4],
          forkthree: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ #5 & \\mbox{#6}\\\\ \\end{array} \\right.", 6],
          forkfour: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ #5 & \\mbox{#6}\\\\ #7 & \\mbox{#8}\\\\ \\end{array} \\right.", 8],
          vecthree: ["\\begin{bmatrix} #1\\\\ #2\\\\ #3 \\end{bmatrix}", 3],
          vecthreethree: ["\\begin{bmatrix} #1 & #2 & #3\\\\ #4 & #5 & #6\\\\ #7 & #8 & #9 \\end{bmatrix}", 9],
          cameramatrix: ["#1 = \\begin{bmatrix} f_x & 0 & c_x\\\\ 0 & f_y & c_y\\\\ 0 & 0 & 1 \\end{bmatrix}", 1],
          distcoeffs: ["(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \\tau_x, \\tau_y]]]]) \\text{ of 4, 5, 8, 12 or 14 elements}"],
          distcoeffsfisheye: ["(k_1, k_2, k_3, k_4)"],
          hdotsfor: ["\\dots", 1],
          mathbbm: ["\\mathbb{#1}", 1],
          bordermatrix: ["\\matrix{#1}", 1]
      }
  }
}
);
//]]>
</script><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
<link href="../../stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<!--#include virtual="/google-search.html"-->
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="../../opencv-logo-small.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">OpenCV
   &#160;<span id="projectnumber">4.5.2</span>
   </div>
   <div id="projectbrief">Open Source Computer Vision</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('../../',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="../../d3/d81/tutorial_contrib_root.html">Tutorials for contrib modules</a></li><li class="navelem"><a class="el" href="../../d0/dda/tutorial_table_of_content_text.html">Text module</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Tesseract (master) installation by using git-bash (version&gt;=2.14.1) and cmake (version &gt;=3.9.1) </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><ol type="1">
<li>We assume you installed opencv and opencv_contrib in c:/lib using [this tutorials](<a href="http://docs.opencv.org/master/d3/d52/tutorial_windows_install.html#tutorial_windows_gitbash_build">http://docs.opencv.org/master/d3/d52/tutorial_windows_install.html#tutorial_windows_gitbash_build</a>]</li>
<li>You must download <a href="https://sourceforge.net/projects/libpng/files/libpng16/1.6.32/lpng1632.zip/download">png lib</a> and <a href="https://sourceforge.net/projects/libpng/files/zlib/1.2.11/zlib1211.zip/download">zlib</a>. Uncompress lpngx.y.zz in folder lpng and zlib in folder zlib. lpng and zlib must be in same folder as opencv and opencv_contrib. save this script with name installpngzlib.sh in c:/lib <div class="fragment"><div class="line">#!/bin/bash</div><div class="line">myRepo=$(pwd)</div><div class="line">CMAKE_CONFIG_GENERATOR=&quot;Visual Studio 14 2015 Win64&quot;</div><div class="line">RepoSource=zlib</div><div class="line">mkdir Build/$RepoSource</div><div class="line">pushd Build/$RepoSource</div><div class="line">cmake . -G&quot;Visual Studio 14 2015 Win64&quot; \</div><div class="line">-DCMAKE_INSTALL_PREFIX:PATH=&quot;$myRepo&quot;/install/zlib -DINSTALL_BIN_DIR:PATH=&quot;$myRepo&quot;/install/zlib/bin \</div><div class="line">-DINSTALL_INC_DIR:PATH=&quot;$myRepo&quot;/install/zlib/include -DINSTALL_LIB_DIR:PATH=&quot;$myRepo&quot;/install/zlib/lib &quot;$myRepo&quot;/&quot;$RepoSource&quot;</div><div class="line">cmake --build . --config release</div><div class="line">cmake --build . --target install --config release</div><div class="line">cmake --build . --config debug</div><div class="line">cmake --build . --target install --config debug</div><div class="line">popd</div><div class="line">RepoSource=lpng</div><div class="line">mkdir Build/$RepoSource</div><div class="line">pushd Build/$RepoSource</div><div class="line">cp &quot;$myRepo&quot;/&quot;$RepoSource&quot;/scripts/pnglibconf.h.prebuilt &quot;$myRepo&quot;/&quot;$RepoSource&quot;/pnglibconf.h</div><div class="line">cmake . -G&quot;Visual Studio 14 2015 Win64&quot; \</div><div class="line">-DZLIB_INCLUDE_DIR:PATH=&quot;$myRepo&quot;/install/zlib/include -DZLIB_LIBRARY_DEBUG:FILE=&quot;$myRepo&quot;/install/zlib/lib/zlibstaticd.lib \</div><div class="line">-Dld-version-script:BOOL=OFF -DPNG_TESTS:BOOL=OFF -DAWK:STRING= \</div><div class="line">-DZLIB_LIBRARY_RELEASE:FILE=&quot;$myRepo&quot;/install/zlib/lib/zlibstatic.lib -DCMAKE_INSTALL_PREFIX=&quot;$myRepo&quot;/Install/&quot;$RepoSource&quot; \</div><div class="line">&quot;$myRepo&quot;/&quot;$RepoSource&quot;</div><div class="line">cmake --build . --config release</div><div class="line">cmake --build . --target install --config release</div><div class="line">cmake --build . --config debug</div><div class="line">cmake --build . --target install --config debug</div><div class="line">popd</div></div><!-- fragment --></li>
<li>In git command line enter the following command : <div class="fragment"><div class="line">./installpngzlib.sh</div></div><!-- fragment --></li>
<li>save this script with name installTesseract.sh in c:/lib <div class="fragment"><div class="line">#!/bin/bash</div><div class="line">function MAJGitRepo</div><div class="line">{</div><div class="line">if [  ! -d &quot;$myRepo/$1&quot;  ]; then</div><div class="line">  echo &quot;clonning ${1}&quot;</div><div class="line">  git clone $2</div><div class="line">  mkdir Build/$1</div><div class="line">else</div><div class="line">  echo &quot;update $1&quot;</div><div class="line">  cd $1</div><div class="line">  git pull --rebase</div><div class="line">  cd ..</div><div class="line">fi</div><div class="line">}</div><div class="line">echo &quot;Installing leptonica and tesseract&quot;</div><div class="line">myRepo=$(pwd)</div><div class="line">CMAKE_CONFIG_GENERATOR=&quot;Visual Studio 14 2015 Win64&quot;</div><div class="line"></div><div class="line">MAJGitRepo leptonica https://github.com/DanBloomberg/leptonica.git</div><div class="line">RepoSource=leptonica</div><div class="line">pushd Build/$RepoSource</div><div class="line">cmake -G&quot;$CMAKE_CONFIG_GENERATOR&quot; -DCMAKE_INSTALL_PREFIX=&quot;$myRepo&quot;/Install/leptonica &quot;$myRepo/$RepoSource&quot;</div><div class="line">echo &quot;************************* $Source_DIR --&gt;debug&quot;</div><div class="line">cmake --build .  --config release</div><div class="line">cmake --build $RepoSource  --target install --config release</div><div class="line">popd</div><div class="line"></div><div class="line">RepoSource=tesseract</div><div class="line">MAJGitRepo $RepoSource https://github.com/tesseract-ocr/tesseract.git</div><div class="line">pushd Build/$RepoSource</div><div class="line">cmake -G&quot;$CMAKE_CONFIG_GENERATOR&quot;  -DBUILD_TRAINING_TOOLS:BOOL=OFF -DCMAKE_INSTALL_PREFIX=&quot;$myRepo&quot;/Install/tesseract -DLeptonica_DIR:PATH=&quot;$myRepo&quot;/Install/leptonica/cmake -DPKG_CONFIG_EXECUTABLE:BOOL=OFF &quot;$myRepo&quot;/&quot;$RepoSource&quot;</div><div class="line">echo &quot;************************* $Source_DIR --&gt;release&quot;</div><div class="line">cmake --build . --config release</div><div class="line">cmake --build .  --target install --config release</div><div class="line"></div><div class="line">popd</div><div class="line">RepoSource=opencv</div><div class="line">pushd Build/$RepoSource</div><div class="line">CMAKE_OPTIONS=&#39;-DBUILD_PERF_TESTS:BOOL=OFF -DBUILD_TESTS:BOOL=OFF -DBUILD_DOCS:BOOL=OFF -DWITH_CUDA:BOOL=OFF&#39;</div><div class="line">cmake -G&quot;$CMAKE_CONFIG_GENERATOR&quot;  \</div><div class="line">-DTesseract_INCLUDE_DIR:PATH=&quot;${myRepo}&quot;/Install/tesseract/include -DTesseract_LIBRARY=&quot;${myRepo}&quot;/Install/tesseract/lib/tesseract400.lib -DLept_LIBRARY=&quot;${myRepo}&quot;/Install/leptonica/lib/leptonica-1.74.4.lib \</div><div class="line">$CMAKE_OPTIONS -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \</div><div class="line">-DINSTALL_CREATE_DISTRIB=ON -DCMAKE_INSTALL_PREFIX=&quot;$myRepo&quot;/install/&quot;$RepoSource&quot;  &quot;$myRepo/$RepoSource&quot;</div><div class="line">echo &quot;************************* $Source_DIR --&gt;devenv debug&quot;</div><div class="line">cmake --build .  --config debug</div><div class="line">echo &quot;************************* $Source_DIR --&gt;devenv release&quot;</div><div class="line">cmake --build .  --config release</div><div class="line">cmake --build .  --target install --config release</div><div class="line">cmake --build .  --target install --config debug</div><div class="line">popd</div></div><!-- fragment --> In this script I suppose you use VS 2015 in 64 bits <div class="fragment"><div class="line">CMAKE_CONFIG_GENERATOR=&quot;Visual Studio 14 2015 Win64&quot;</div></div><!-- fragment --> and leptonica, tesseract will be installed in c:/lib/install <div class="fragment"><div class="line">-DCMAKE_INSTALL_PREFIX=&quot;$myRepo&quot;/install/&quot;$RepoSource&quot; &quot;$myRepo/$RepoSource&quot;</div></div><!-- fragment --> with no Perf tests, no tests, no doc, no CUDA and no example <div class="fragment"><div class="line">CMAKE_OPTIONS=&#39;-DBUILD_PERF_TESTS:BOOL=OFF -DBUILD_TESTS:BOOL=OFF -DBUILD_DOCS:BOOL=OFF  -DWITH_CUDA:BOOL=OFF -DBUILD_EXAMPLES:BOOL=OFF&#39;</div></div><!-- fragment --></li>
<li>In git command line enter the following command : <div class="fragment"><div class="line">./installTesseract.sh</div></div><!-- fragment --></li>
<li>now we need the language files from tesseract. either clone <a href="https://github.com/tesseract-ocr/tessdata,">https://github.com/tesseract-ocr/tessdata,</a> or copy only those language files you need to a folder (example c:\lib\install\tesseract\tessdata). If you don't want to add a new folder you must copy language file in same folder than your executable</li>
<li>if you created a new folder, then you must add a new variable, TESSDATA_PREFIX with the value c:\lib\install\tessdata to your system's environment</li>
<li>add c:\Lib\install\leptonica\bin and c:\Lib\install\tesseract\bin to your PATH environment. If you don't want to modify the PATH then copy tesseract400.dll and leptonica-1.74.4.dll to the same folder than your exe file. </li>
</ol>
</div></div><!-- contents -->
<!-- HTML footer for doxygen 1.8.6-->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Apr 2 2021 11:36:39 for OpenCV by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="../../doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
<script type="text/javascript">
//<![CDATA[
addTutorialsButtons();
//]]>
</script>
</body>
</html>
